<style scoped>
.expand-row {
    margin-bottom: 16px;
}
</style>
<template>
    <div>
        <Row class="expand-row" v-for="item in data">
            <Col span="1">　&nbsp;
            </Col>
            <Col span="6">
            <span class="expand-key" v-show="item.authorize==2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;操作人帐号: </span>
            <span class="expand-key" v-show="item.authorize==3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;客户帐号: </span>
            <span class="expand-value">{{ item.username }}</span>
            </Col>
            <Col span="6">
            <span class="expand-key">密码: </span>
            <span class="expand-value">{{ item.password}}</span>
            </Col>
            <Col span="6">
            <Button type="primary" icon="ios-create" size="small" :title=item.password :data-auth=item.authorize @click="editData($event)" :id=item.id >编辑</Button>
            </Col>
        </Row>
        <Modal v-model="editDataModalFlag" :title="eDF_Title" @on-ok="edit_operator('formValidate')" :mask-closable="false">
            <Form :label-width="100" ref="formValidate" :rules="ruleValidate" :model="formValidate">
               <!--  <FormItem label="帐号" prop="coname">
                   <Input placeholder="输入帐号" class="input-select-class" v-model="formValidate.coname"></Input>
               </FormItem> -->
                <FormItem label="密码" prop="password2">
                    <Input placeholder="输入密码" class="input-select-class" v-model="editpass"></Input>
                </FormItem>
            </Form>
        </Modal>
    </div>
</template>
<script>
export default {
    props: {
        row: Object
    },
    data() {
        return {
            data: [],
            formValidate: {

                password: '',

            },
            ruleValidate: {

                password: [{
                    required: true,
                    message: '密码不能为空',
                    trigger: 'blur'
                }],


            },
            editid: 0,
            editpass:"",
            editDataModalFlag: false,
            eDF_Title: '',

        }
    },
    methods: {
        editData(event) {
            var self = this;
            self.editDataModalFlag = true;
            var el = event.currentTarget;
            self.eDF_Title=el.dataset.auth=='2'?'编辑操作人':'编辑客户帐号';
            self.editid=el.id;
            self.editpass=el.title;
            console.log(el.title);
        },
        edit_operator(name) {
            this.$refs[name].validate((valid) => {
                if (valid) {
                    var self = this
                    console.log(self.editid,self.editpass)
                        //console.log(self.changeDate(self.formValidate.sdate))

                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=useredit",
                        data: {
                            "id": self.editid,
                            "password": self.editpass,
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {

                            console.log(data);
                            self.$router.push({
                                path: '/'
                            })
                            self.$Message.success('修改成功!')


                        }
                    });


                } else {
                    this.$Message.error('表单验证失败!')
                }
            })

        },
    },
    created() {

        var self = this;


        console.log(this.row);


        if (this.row.users!=null) {

            self.data = this.row.users
            console.log(self.data);

        } else {

             this.$Message.error('没有操作人!')

        }

    }


};
</script>
